<?php

//require_once 'PHPUnit/Framework/TestCase.php';
require_once 'PHPUnit/Framework.php';
require_once('TVB/pms/pdes/action/LoginAction.class.php');
require_once('TVB/pms/pdes/util/functions.php');

class ChapterAddActionTest extends PHPUnit_Framework_TestCase
{

	protected function setUp()
	{
		$this->url = "http://pdes.tvb.com/add_chapter.html?ut=true";
	}

	protected function tearDown()
	{
		$this->url = NULL;
	}

	public function testSuccess(){

		$success_data = array(
			//-- add record{{{
			'programme_id' => 2,
			'ii_id' => '2009',
			'title' => 'tvb',
			'subtitle' => 'tvb',
			'description' => 'big data',
			'personage' => ' data',
			'folder' => 'big data',
			'tags' => 'big data',
			'status' => '2009',
			'created_by' => 'tvb',
			'modified_by' => 'tvb',
			'location' => 'big data',
			'location_type' => 'big data',
			'licenses' => 'big data',
			//}}}
		);

		$ret = curl_test($this->url,$success_data);
		$real_data = json_decode($ret);
		$err_num = count($real_data);
		if ($err_num == 0)
		{
			echo "ChapterAddActionTest pass!<br>";
		}

		$this->assertEquals($err_num, 0); 	
	}

	public function testFailed(){

		$success_data = array(
			//-- add record{{{
			'programme_id' => '2009',
			'real_name' => 'tvb',
			'fake_name'=> 'tvb',
			'nickname' => 'tvb',
			'gender' => 'tvb',
			'age' => '2009',
			'occupation' => 'tvb',
			'personality' => 'tvb',
			'profile' => 'big data',
			'history' => 'big data',
			'folder' => 'big data',
			'tags' => 'big data',
			'status' => '2009',
			//}}}
		);

		$ret = curl_test($this->url,$success_data);
		$real_data = json_decode($ret);

		$err_num = count($real_data);
		if ($err_num > 0)
		{
			echo "ChapterAddActionTest failed!";
		}

		$this->assertEquals($err_num , 0); 	
	}
}

$suite = new PHPUnit_Framework_TestSuite('ChapterAddActionTest');

// Run the tests
$object = $suite->run();
//var_dump($object->failures());

?>


